<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script language="Javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/paging.js"></script>

<script language="JavaScript">
	$(document).ready(function() {
		$("#allsts").change(function() {
			var isChecked = $('.selsts').attr('checked') ? true : false;
			if (isChecked == false) {
				$(".selsts").attr('checked', true);
			} else {
				$(".selsts").attr('checked', false);
			}

		});

		$('#search').keyup(function() {
			searchTable($(this).val());
		});

		$("#example").tablesorter({
			// pass the headers argument and assing a object 
			headers : {
				// assign the secound column (we start counting zero) 
				0 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				// assign the third column (we start counting zero) 
				5 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				6 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				3 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				4 : {
					// disable it by setting the property sorter to false 
					sorter : false
				}
			}
		});
	});

	function searchTable(inputVal) {
		var table = $('#example');
		table.find('tr').each(function(index, row) {
			var allCells = $(row).find('td');
			if (allCells.length > 0) {
				var found = false;
				allCells.each(function(index, td) {
					var regExp = new RegExp(inputVal, 'i');
					if (regExp.test($(td).text())) {
						found = true;
						return false;
					}
				});
				if (found == true)
					$(row).show();
				else
					$(row).hide();
			}
		});
	}
</script>

<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
#top{
	top: 0;
}
.scrollable { width:1100px; height:500px; overflow-y:auto; overflow-x:auto; clip-rect:(0px, 1100px, 500px, 0px); }
</style>
</head>
<body>
	<div align="left">
	<s:actionerror />
	</div>
	<table><tr><td  width="1060" id="top" valign="top">
		<a href="#" id="addrow"><font style="font-size: small;"><img alt="" src="images/plus.png">Add New Room</font></a>
		&emsp;
						<a href="javascript:void(0);"
				onclick="PopupCenter('admin/UploadRoomExcel.jsp','batch',300,300);"><font style="font-size: small;"><img alt="" src="images/upload.png">Upload a Room Excel Sheet
				</font></a>
				</td><td width="500" align="right"><img alt="" src="images/search.png"><input type="text" id="search" size="50" />
		</td><td width="20"></td>
		</tr></table>
	
	<form id="form" action="deleteroom.action" method="post">
	<div class="scrollable">
	<table id="example" class="tablesorter" width="100%" style="border-color: gray; border-style: solid; border-width: thin;">
		<thead>
			<tr>
			<th><input type="checkbox" id="allsts" /></th>
				<th>Room Id</th>
				<th>Occupant Id</th>
				<th>Room Number</th>
				<th>Residential Name</th>
				<th>Description</th>
				<th></th>
				<th></th>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="studentDetailsList">
			<tr>
						<td><input type="checkbox" class="selsts" value='<s:property value="room_id" />' name="room_id"/></td>
				<td><s:property value="room_id" /></td>
				<s:if test='roll_number.equals("--")'>
				<td>Unassigned</td>
				</s:if>
				<s:else>
				<td><s:property value="roll_number" /></td>
				</s:else>
				<td><s:property value="room_number" /></td>
				<td><s:property value="residential_name" /><input type="hidden" name="residential_id1" value='<s:property value="residential_id"/>'/></td>
				
				<td><s:property value="description" /></td>
				<td><a href="editHostelDetails.action?residential_id=<s:property value="residential_id"/>&room_id=<s:property value="room_id"/>&type=getroomdetails">EDIT</a></td>
				<td><a href="deleteroom.action">DELETE</a></td>
			
			</tr>
			</s:iterator>
			</tbody>
			<tfoot>
			<tr>
				<th colspan="3">Total result&emsp; <b><s:property value="result"/> </b></th>
				<th style="font-family: calibri; font-size: small; font-weight: bold; background-color: #e6EEEE;" colspan="8" align="right">
					&emsp;&emsp;
                    <s:set name="hasmore" value="morepages"/>
                    <s:if test="%{#hasmore=='false'}">

             <s:url id="url11" action="hostelstudents.action" encode="true">
             		<s:param name="residential_id"><s:property value="#session['residential_id']"/> </s:param>
                    <s:param name="page"><s:property value="prevpage"/> </s:param>
             </s:url>
                    <s:a href="%{url11}">Prev</s:a>
                    </s:if>






 <s:iterator  value="noofpages" status="stat" var="element">

              <s:url id="url10" action="hostelstudents.action" encode="true">
					<s:param name="residential_id"><s:property value="#session['residential_id']"/> </s:param>
                    <s:param name="page"><s:property value="%{#element}"/></s:param>
             </s:url>

            <s:set name="current" value="currentpage"/>
                <s:if test="%{#current==#element}">
                    <s:a href="%{url10}"><s:property value="%{#element}"/></s:a>
                </s:if>

                <s:else>
                    <s:a href="%{url10}"><s:property value="%{#element}"/></s:a>
                </s:else>

</s:iterator>

            <s:set name="hasmore" value="morepages"/>
                    <s:if test="%{#hasmore=='true'}">

             <s:url id="url11" action="hostelstudents.action" encode="true">
             		<s:param name="residential_id"><s:property value="#session['residential_id']"/> </s:param>
                    <s:param name="category"><s:property value="category" /></s:param>
                    <s:param name="page"><s:property value="nextpage"/> </s:param>
             </s:url>

                    <s:a href="%{url11}">Next</s:a>
                    </s:if>
					&emsp;&emsp;
				</th>
			</tr>
		</tfoot>
		
	</table>
	</div>
	<div><table width="800px"><tr><td><input type="submit" value="Delete Selected Items"/></td></tr></table></div>
	</form>
		
		
		
		
		
		
	
</body>
</html>